// pages/CustomizeCmpt/PureDataField/pure-data-field.js
Component({
  options: {
    // 所有_开头的数据字段为纯数据字段
    pureDataPattern: /^_/
  },
  properties: {
    commonProp: String,
    _pureProp: { // 可正常接收外部传入值
      type: String,
      // 纯数据字段的observer永远不会被触发，可以通过observers数据监听器监听
      observer: function() {console.log('_pureProp-observer')}
    }
  },
  data: {
    commonData: '普通字段',
    _pureData: '纯数据字段'
  },
  observers: {
    'commonProp, _pureProp, commonData, _pureData': function(commonProp, _pureProp, commonData, _pureData) {
      // observers commonProp _pureProp commonData _pureData
      console.log('observers' ,commonProp, _pureProp, commonData, _pureData)
    }
  },
  methods: {
    handleChange() {
      // 普通字段 纯数据字段 普通字段 纯数据字段
      console.log(this.properties.commonProp, this.properties._pureProp, this.data.commonData, this.data._pureData)

      this.setData({
        commonProp: 'commonProp',
        _pureProp: '_pureProp',
        commonData: 'commonData',
        _pureData: '_pureData'
      })

      // commonProp _pureProp commonData _pureData
      console.log(this.properties.commonProp, this.properties._pureProp, this.data.commonData, this.data._pureData)
    }
  }
})
